import 'package:flutter/material.dart';

/// 发现页面（类似微信的发现页面）
class ChatPage extends StatelessWidget {
  const ChatPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('发现'),
        automaticallyImplyLeading: false, // 禁用回退按钮
        elevation: 0,
      ),
      backgroundColor: const Color(0xFFF5F7FA),
      body: ListView(
        padding: const EdgeInsets.symmetric(vertical: 8),
        children: [
          // 朋友圈（暂时占位）
          _buildSection(
            context: context,
            children: [
              _buildMenuItem(
                context: context,
                icon: Icons.photo_library_outlined,
                title: '朋友圈',
                iconColor: const Color(0xFF5B8DEF), // 主蓝色
                onTap: () {
                  ScaffoldMessenger.of(context).showSnackBar(
                    const SnackBar(content: Text('朋友圈功能开发中')),
                  );
                },
              ),
            ],
          ),
          
          const SizedBox(height: 12),
          
          // 扫一扫、摇一摇等
          _buildSection(
            context: context,
            children: [
              _buildMenuItem(
                context: context,
                icon: Icons.qr_code_scanner_outlined,
                title: '扫一扫',
                iconColor: const Color(0xFF5B8DEF), // 主蓝色
                onTap: () {
                  ScaffoldMessenger.of(context).showSnackBar(
                    const SnackBar(content: Text('扫一扫功能开发中')),
                  );
                },
              ),
              Divider(height: 1, indent: 64),
              _buildMenuItem(
                context: context,
                icon: Icons.vibration_outlined,
                title: '摇一摇',
                iconColor: const Color(0xFF5B8DEF), // 主蓝色
                onTap: () {
                  ScaffoldMessenger.of(context).showSnackBar(
                    const SnackBar(content: Text('摇一摇功能开发中')),
                  );
                },
              ),
            ],
          ),
          
          const SizedBox(height: 12),
          
          // 小程序、游戏等
          _buildSection(
            context: context,
            children: [
              _buildMenuItem(
                context: context,
                icon: Icons.apps_outlined,
                title: '小程序',
                iconColor: const Color(0xFF5B8DEF), // 主蓝色
                onTap: () {
                  ScaffoldMessenger.of(context).showSnackBar(
                    const SnackBar(content: Text('小程序功能开发中')),
                  );
                },
              ),
              Divider(height: 1, indent: 64),
              _buildMenuItem(
                context: context,
                icon: Icons.sports_esports_outlined,
                title: '游戏',
                iconColor: const Color(0xFF5B8DEF), // 主蓝色
                onTap: () {
                  ScaffoldMessenger.of(context).showSnackBar(
                    const SnackBar(content: Text('游戏功能开发中')),
                  );
                },
              ),
            ],
          ),
        ],
      ),
    );
  }

  Widget _buildSection({
    required BuildContext context,
    required List<Widget> children,
  }) {
    return Container(
      margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(8),
        boxShadow: [
          BoxShadow(
            color: Colors.black.withOpacity(0.02),
            blurRadius: 4,
            offset: const Offset(0, 1),
          ),
        ],
      ),
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: children,
      ),
    );
  }

  Widget _buildMenuItem({
    required BuildContext context,
    required IconData icon,
    required String title,
    String? subtitle,
    Color? iconColor,
    VoidCallback? onTap,
    Widget? trailing,
  }) {
    // 默认使用灰色图标，更符合大众审美
    final defaultIconColor = Colors.grey[700] ?? Colors.black87;
    final finalIconColor = iconColor ?? defaultIconColor;
    
    return InkWell(
      onTap: onTap,
      borderRadius: BorderRadius.circular(8),
      child: Container(
        padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
        child: Row(
          children: [
            Container(
              width: 36,
              height: 36,
              decoration: BoxDecoration(
                color: finalIconColor.withOpacity(0.1),
                borderRadius: BorderRadius.circular(8),
              ),
              child: Icon(
                icon,
                color: finalIconColor,
                size: 20,
              ),
            ),
            const SizedBox(width: 12),
            Expanded(
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text(
                    title,
                    style: const TextStyle(
                      fontSize: 16,
                      fontWeight: FontWeight.w500,
                    ),
                  ),
                  if (subtitle != null) ...[
                    const SizedBox(height: 2),
                    Text(
                      subtitle,
                      style: TextStyle(
                        fontSize: 12,
                        color: Colors.grey[600],
                      ),
                    ),
                  ],
                ],
              ),
            ),
            if (trailing != null)
              trailing
            else
              Icon(
                Icons.chevron_right,
                color: Colors.grey[400],
                size: 20,
              ),
          ],
        ),
      ),
    );
  }
}

